#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

 struct Node {
      int val;
     struct Node *next;
      struct Node *random;
 };
 

struct Node* copyRandomList(struct Node* head) {
    if (head == NULL)
    {
        return NULL;
    }
    struct Node* node = head;
    while (node)
    {
        struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
        newNode->val = node->val;
        newNode->next = node->next;
        node->next = newNode;
        node = node->next->next;
    }
    node = head;
    while (node)
    {
        struct Node* newNode = node->next;
        newNode->random = (node->random != NULL) ? (node->random->next) : NULL;
        node = node->next->next;
    }
    struct Node* newhead = head->next;
    node = head;
    while (node)
    {
        struct Node* newNode = node->next;
        node->next = node->next->next;
        newNode->next = (newNode->next != NULL) ? (newNode->next->next) : NULL;
        node = node->next;
    }
    return newhead;
}
int main()
{
    return 0;
}